﻿@{
    ViewData["Title"] = "学生列表";
    int Length = ViewBag.page.Count;
    bool Previous = ViewBag.Previous;
    bool Next = ViewBag.Next;
}
@model List<Student>
<div class="card-body">
    <table class="table">
        <thead class="table-active">
            <tr>
                <th><span>学号</span></th>
                <th><span>姓名</span></th>
                <th><span>性别</span></th>
                <th style="display:block;" class="text-center"><span>操作</span></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@item.SNo</td>
                    <td>@item.Name</td>
                    <td>@item.Gender</td>
                    <td style="display:block;width:300px;margin:0 auto;" class="text-center">
                        <a class="btn btn-primary" asp-action="GetStudent" asp-controller="home" asp-route-Id="@item.Id">详细</a>
                        <a class="btn btn-primary" asp-action="UpdateStudent" asp-controller="home" asp-route-Id="@item.Id">修改</a>
                        <form asp-action="DeleteStudent" asp-route-Id="@item.Id" method="post" style="display:inline">
                            <button class="btn btn-danger" type="submit" onclick="return confirm('确认要删除吗？')">
                                删除
                            </button>
                        </form>
                    </td>
                </tr>
            }

        </tbody>
    </table>
    <div style="margin:0 auto;width:500px;position:absolute;top:500px;left:500px">
        <ul class="pagination" tyle="margin:0 auto;">
            @if (ViewBag.page.HasPrevious == true)
            {
                <li class="page-item"><a class="page-link" asp-action="index" asp-route-PageIndex="@(ViewBag.page.PageIndex-1)">&laquo;</a></li>
            }
            @for (int i = 1; i <= Length; i++)
            {
                <li class="page-item"><a class="page-link" name="PageIndex" asp-action="index" asp-route-PageIndex="@i">@i</a></li>
            }
            @if (ViewBag.page.HasNext == true)
            {
                <li class="page-item"><a class="page-link" asp-action="index" asp-route-PageIndex="@(ViewBag.page.PageIndex+1)">&raquo;</a></li>
            }
            <br />
            <span>当前页数</span>
            <input type="text" readonly="readonly" class="form-control" style="width:50px" value="@ViewBag.page.PageIndex" />

        </ul>
    </div>
    <script>
        console.log(@Length.ToString())
    </script>

</div>
